var tree = {
    id: '1',
    name: 'node1',
    children:[
        {id: '2', name: 'node2',value:2},
        {id: '3', name: 'node3',value:3,children:[
            {id: '5', name: 'node2',value:5},
            {id: '6', name: 'node4',value:6},
            {id: '11', name: 'node4',value:6},
        ]},
        {id: '4', name: 'node4',value:4},
        
    ]
}

function compute(node){
    var sumValue;
    if(node.value>10){
        sumValue = 10;
    }else{
        sumValue = node.value;
    }
    if(node.children){
        for(var i=0;i<node.children.length;i++){
            sumValue += compute(node.children[i]);
        }
    }
    console.log(sumValue);
    return sumValue;
}
console.log(compute(tree));